import React, { Component } from 'react'

export default class LifeChild extends Component {

    state = {
        count: 10
    }

    // callback = () => {

    // }
    addCount = () => {


        // //  setState 异步  最后一次输送结果
        // this.setState({
        //     count: this.state.count + 20
        // })

        // this.setState(preState => {
        //     console.log(preState)
        //     return {
        //         count: preState.count + 10
        //     }
        // }, () => {
        //     console.log('回调函数的', this.state.count)
        //     // axios.get('url',params:{data: this.state.count})

        // })



        // this.setState(preState => ({ count: preState.count + 10 })

        //     , () => {
        //         console.log('回调函数的', this.state.count)
        //         // axios.get('url',params:{data: this.state.count})

        //     })


        this.setState(preState => ({ count: preState.count + 1 }))

        this.setState(preState => ({ count: preState.count + 2 }))
        this.setState(preState => ({ count: preState.count + 3 }), () => {
            console.log('回调函数 值;', this.state.count)
        })


        console.log('setState 后面的值 外面;', this.state.count)








    }

    render () {
        console.log('render', this.state.count)
        return (
            <>
                <hr />
                <div>LifeChild ----{this.state.count}</div>

                <button onClick={this.addCount}> 点击</button>
            </>

        )
    }
}
